package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppMingXiSongLi;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author anxiang
 * @version 1.0.0
 * @ClassName AppMingXiSongLiDao.java
 * @Description 送礼明细
 * @createTime 2021年11月02日 15:13:00
 */
@Repository
public class AfterMingXiSongLiDao extends BaseDao<AppMingXiSongLi> {

    /**
     * 新增或更新
     * @param appMingXiSongLi
     */
    public void saveOrUpdate(AppMingXiSongLi appMingXiSongLi) {
        if (appMingXiSongLi.getId() == null || appMingXiSongLi.getId() == 0) {
            appMingXiSongLi.setId(this.add(appMingXiSongLi));
        } else {
            this.update(appMingXiSongLi);
        }
    }

    /**
     *  查找用户送礼明细
     */
    public List<AppMingXiSongLi> findList(String userid, SplitPageBean splitPageBean) {
        if (StringEx.isNull(userid)) {
            return null;
        }
        StringBuilder str = new StringBuilder();
        List<Object> list = new ArrayList<>();
        str.append("select * from app_mingxi_songli where 1=1 ");
        str.append(" and userid = ? ");
        list.add(userid);
        String sql = str.toString();
        return this.queryList(sql, list, AppMingXiSongLi.class, splitPageBean);
    }
}